import { getCompanyInfo } from '../../api/user/user'
const wxParse = require('../../wxParse/wxParse.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        config:{},
        questionList:[],
    },

    onLoad: function (options) {
        this.getQuestion()
        this.getIntegralConfig()
    },
    onReady: function () {

    },


    onShow: function () {
    },

    onHide: function () {

    },

    onUnload: function () {

    },

    showAll:function(e){
        let { index } = e.currentTarget.dataset;
        console.log(e.currentTarget.dataset)
        let showButtons = `questionList[${index}].showButtons`
        this.setData({
            [showButtons]: !this.data.questionList[index].showButtons
        })
    },

    onPullDownRefresh: function () {

    },

    onReachBottom: function () {

    },

    toTiaoKuan(){
        wx.navigateTo({
          url: '../police/police',
        })
    },
    getIntegralConfig(){
        var that = this;
        wx.$api.getIntegralConfig().then(res=>{
            if(res.code){
                that.setData({
                    config:res.data
                })
            }
        })
    },
    getQuestion(){
        var that = this;
        wx.$api.ArticleGetProblem().then(res=>{
            var resArray = res.data
            for (let i = 0; i < resArray.length; i++) {
                wxParse.wxParse('content' + i, 'html', resArray[i].article_content, that,5);
                //delete newData[i].content;
                if (i === resArray.length - 1) {
                    wxParse.wxParseTemArray("wxParseListArr",'content', resArray.length, that,5)
                }
                resArray[i].article_title = resArray[i].article_title.replace(/--&gt;/,' --> ')
            }
            that.setData({
                questionList:resArray
            })
        })
    }
})